//
//  DHPayPasswordController.m
//  DHJPHotel
//
//  Created by 123 on 2018/5/25.
//  Copyright © 2018年 Apple. All rights reserved.
//

#import "DHPayPasswordController.h"

@interface DHPayPasswordController ()
@property (weak, nonatomic) IBOutlet UITextField *oldPwdTxt;
@property (weak, nonatomic) IBOutlet UITextField *pwdNewTxt;



@end

@implementation DHPayPasswordController

- (void)viewDidLoad {
    [super viewDidLoad];
    
   
}

#pragma mark: - 提交按钮
- (IBAction)commitButtonClick:(UIButton *)sender {
    
    if (!self.oldPwdTxt.hasText) {[SVProgressHUD showInfoWithStatus:@"请输入密码"];return;}
     if (!self.pwdNewTxt.hasText) {[SVProgressHUD showInfoWithStatus:@"请输入确认密码"];return;}

    
    if (![self.pwdNewTxt.text isEqualToString:self.oldPwdTxt.text]) {
        [SVProgressHUD showInfoWithStatus:@"密码不一致，请重新输入"];return;
    }
    
    NSString *url = [NSString stringWithFormat:@"%@%@",REMOTEURL,@"index.php?act=member_security&op=modify_paypwd"];
    NSMutableDictionary *dictM = [NSMutableDictionary dictionary];
    dictM[@"auth_modify_paypwd"] = @(self.auth_modify_paypwd);
    dictM[@"password"] = self.oldPwdTxt.text;
    dictM[@"confirm_password"] = self.pwdNewTxt.text;
    
    [DHNetworkManager.shareManager requestWithMethod:MethodPost UrlString:url params:dictM.copy completion:^(id json, BOOL isSuccess)
    {
        if (!isSuccess) {
            [SVProgressHUD showInfoWithStatus:@"请检查网络"];
            return ;
        }
        if (json[@"datas"][@"error"]) {
            [SVProgressHUD showErrorWithStatus:json[@"datas"][@"error"]];
            return;
        }
        [SVProgressHUD showSuccessWithStatus:@"操作成功"];
        [self.navigationController popToViewController:self.navigationController.childViewControllers[1] animated:true];
    }];
    
}


@end
